<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>流程设计</title>

</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12 col-sm-12 col-xs-12">
            <div class="widget  no-padding">
                <div class="widget-header bg-themeprimary">
                    <i class="widget-icon typcn typcn-th-list"></i>
                    <span class="widget-caption"></span>
                </div>
                <div class="widget-body">
                    <table class="table table-bordered form" id="grid">
                        <thead>
                        <tr>
                            <th>模板名称</th>
                            <th>类名称</th>
                            <th style="width: 200px;">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr class="row-no-display">
                            <td>$templateName$</td>
                            <td>$packageName$</td>
                            <td style="text-align: center;">
                                <a rel='defineDesigner' class="btn btn-info btn-xs edit"><i
                                        class="fa fa-edit"></i><span>流程</span></a>
                                <a rel='defineForm' class="btn btn-info btn-xs edit"><i
                                        class="fa fa-edit"></i><span>表单</span></a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade form bs-example-modal-md" id="modalTemplate" role="dialog"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="widget no-padding">
                <div class="widget-header bg-themeprimary">
                    <i class="widget-icon fa fa-user"></i>
                    <span class="widget-caption">流程模板</span>
                    <div class="widget-buttons">
                        <a tabindex="7" data-type="reset"><i class="fa fa-refresh"></i></a>
                        <a data-dismiss="modal">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="widget-body">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label
                                    class="col-sm-2 col-lg-2 col-md-2 col-xs-12 control-label no-padding-right"
                                    for="templateName">模板名称</label>
                            <div class="col-lg-10 col-sm-10 col-md-10 col-xs-12">
                                <input name="templateName" id="templateName" class="form-control" value=""></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-lg-2 col-md-2 col-xs-12 control-label no-padding-right"
                                   for="imgurl">
                                图标
                            </label>
                            <div class="col-lg-10 col-sm-10 col-md-10 col-xs-12">
                                <input name="imgurl" class="form-control" id="imgurl" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-8 col-sm-4" style="text-align: right;">
                                <a class="btn btn-success" id="btnAdd" href="#"><i
                                        class="fa fa-check right"></i>保存</a>
                                <a class="btn btn-danger" href="#" data-dismiss="modal"><i
                                        class="fa fa-times right"></i>关闭</a>
                            </div>
                        </div>
                        <input style="display: none;" type="reset" value="重置"></form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function init() {
        var modal = $('#modalTemplate');
        var gridparms={
            template:{
                keys: ['templateName','packageName'],
                url: "/workflow/template/query/all",
                placeholder: '流程名称',
                tools: [{
                    'text': '新增',
                    'event': function () {
                        gridparms.template.insert = true;
                        modal.trigger('reset');
                        modal.modal();
                    }
                }],
                events: {
                    defineForm: function (row) {
                        pageParm.template = row;
                        loadpage("/views/workflow/form.html");
                    },
                    defineDesigner: function (row) {
                        pageParm.template = row;
                        loadpage("/views/workflow/workflow.html", true);
                    }
                }
            }
        }

       var validateList = {
            'template': {
                'fields': {
                    'templateName': {'validators': {'notEmpty': {}}},
                    'imgurl': {'validators': {'notEmpty': {}}}
                },
                'submitHandler': function (obj, $this) {

                    obj.insert=gridparms.template.insert;

                    $.request("/workflow/template/save",obj,function(){
                        gridparms.template.ext.refresh();
                        $this.modal('hide');
                    })
                },
                'submitBtn': 'btnAdd'
            }
        }
        $("#grid").table(gridparms.template);
        modal.validate(validateList.template);

    }


</script>
</body>
</html>